package transaction.lcn.order.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import transaction.lcn.order.service.OrderService;

@RequestMapping("/lcn/order")
@RestController
public class OrderController {

    @Autowired
    OrderService orderService;

    // gateway http://localhost:9100/lcn-order/lcn/order/debit?userId=1001&commodityCode=2001&count=1
    @GetMapping(value = "/debit")
    public Object debit(@RequestParam String userId, @RequestParam String commodityCode, @RequestParam Integer count) {
        return orderService.create(userId, commodityCode, count);
    }

    @RequestMapping("/buySth")
    @ResponseBody
    public String buySomethingProxy(@RequestParam int userId,@RequestParam int money){
        return orderService.buySomething(userId, money);
    }

}
